import { SDKTools } from "../SDKTools";
import { IMiniGameRunTime } from "./IMiniGameRunTime";
import { KSRunTimeSDK } from "./KSRunTimeSDK";

export class MiniGameRunTimeMgr {
    private static _instance: MiniGameRunTimeMgr = null;
    public static get instance(): MiniGameRunTimeMgr {
        if (!this._instance) {
            this._instance = new MiniGameRunTimeMgr();
        }
        return this._instance;
    }
    private constructor() { }
    private _isInit: boolean = false;
    private runTime: IMiniGameRunTime = null;
    public static async Init() {
        if (this.instance._isInit) {
            return;
        }
        this.instance._isInit = true;
        if (SDKTools.isAliPay) {
            this.instance.runTime = null;
        } else if (SDKTools.isWeChat) {
            this.instance.runTime = null;
        } else if (SDKTools.isKSGame) {
            this.instance.runTime = new KSRunTimeSDK();
        }
    }
    public static async ApiLoin(): Promise<string> {
        if(SDKTools.isdebug) return "debug";
        return await this.instance.runTime.login();
    }
}